<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Signal Emission and Propagation</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="GTK+ 2.0 Tutorial"
HREF="book1.html"><LINK
REL="UP"
TITLE="Advanced Event and Signal Handling"
HREF="c1799.html"><LINK
REL="PREVIOUS"
TITLE="Advanced Event and Signal Handling"
HREF="c1799.html"><LINK
REL="NEXT"
TITLE="Managing Selections"
HREF="c1836.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GTK+ 2.0 Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c1799.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Advanced Event and Signal Handling</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="c1836.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-SIGNALEMISSIONANDPROPAGATION"
>Signal Emission and Propagation</A
></H1
><P
>Signal emission is the process whereby GTK runs all handlers for a
specific object and signal.</P
><P
>First, note that the return value from a signal emission is the return
value of the <I
CLASS="EMPHASIS"
>last</I
> handler executed. Since event signals are
all of type <TT
CLASS="LITERAL"
>GTK_RUN_LAST</TT
>, this will be the default (GTK supplied)
handler, unless you connect with gtk_signal_connect_after().</P
><P
>The way an event (say "button_press_event") is handled, is:</P
><P
></P
><UL
><LI
><P
>Start with the widget where the event occured.</P
></LI
><LI
><P
>Emit the generic "event" signal. If that signal handler returns
a value of TRUE, stop all processing.</P
></LI
><LI
><P
>Otherwise, emit a specific, "button_press_event" signal. If that
returns TRUE, stop all processing.</P
></LI
><LI
><P
>Otherwise, go to the widget's parent, and repeat the above two
steps.</P
></LI
><LI
><P
>Continue until some signal handler returns TRUE, or until the
top-level widget is reached.</P
></LI
></UL
><P
>Some consequences of the above are:</P
><P
></P
><UL
><LI
><P
>Your handler's return value will have no effect if there is a
default handler, unless you connect with gtk_signal_connect_after().</P
></LI
><LI
><P
>To prevent the default handler from being run, you need to
connect with gtk_signal_connect() and use
gtk_signal_emit_stop_by_name() - the return value only affects whether
the signal is propagated, not the current emission.</P
></LI
></UL
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c1799.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="c1836.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Advanced Event and Signal Handling</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c1799.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Managing Selections</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>